=========================================================================== BBS: The Abacus * HST/DS * Potterville MI Date: 03-02-93 (19:48) Number: 287 From: JOE NEGRON Refer#: 36 To: KEITH WATKINS Recvd: NO Subj: Re: COMMAND LINE Conf: (35) Quick Basi --------------------------------------------------------------------------- KW> There are some programs out there that have command line switches > like /A /NOMENU C:\COMM ect. ect. It seems not to matter the order > they are placed in for the program to understand what to do with > them. How is this done? GS> There are at least a couple of ways to do this. I have a routine > here that parses the command line arguments, and does it's thing > from there. I can't post it here, as it is copyrighted. > There is a book called QuickBASIC Primer Plus that has > such a routine in it, as well. Here it is: ============================== Begin code ============================== DEFINT A-Z DECLARE SUB ParseCmdLine (Args$(), NArgs%) '*********************************************************************** '* SUB ParseCmdLine '* '* PURPOSE '* Retrieves the command line and splits into arguments. '*********************************************************************** SUB ParseCmdLine (Args$(), NArgs%) STATIC CONST FALSE = 0, TRUE = -1, HT = 9 'the upper and lower bounds of the passed array 'determine the maximum number of arguments to return MaxArgs% = UBOUND(Args$) - LBOUND(Args$) + 1 In% = FALSE Cmd$ = COMMAND$ Length% = LEN(Cmd$) FOR Check% = 1 TO Length% 'loop once for each char in ' COMMAND$ Ch$ = MID$(Cmd$, Check%, 1) 'extract current character 'look for a blank or tab IF (Ch$ <> " " AND Ch$ <> CHR$(HT)) THEN IF NOT In% THEN 'found start of a new arg IF NArgs% = MaxArgs% THEN EXIT FOR 'test for too many args END IF NArgs% = NArgs% + 1 'increment number of args ' counter In% = TRUE 'set "In argument" flag to END IF ' TRUE Args$(NArgs%) = Args$(NArgs%) + Ch$ 'add char to end of Args$() ELSE 'found a blank or tab In% = FALSE END IF NEXT Check% Cmd$ = "" Ch$ = "" END SUB =============================== End code =============================== Make sure you DIMension Args$() to the number of parameters you want to retrieve from the command line. --Joe in Bay Ridge, Brooklyn, NY-- Tue 03-02-1993, 19:48 ... Don't take life too seriously, it's not permanent. ___ X Blue Wave/QWK v2.12 X --- Maximus 2.01wb * Origin: * BlueDog BBS * (212) 594-4425 * NYC FileBone Hub (1:278/709) SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1 SEEN-BY: 153/752 154/40 77 157/2 159/100 125 430 950 203/23 209/209 280/1 SEEN-BY: 390/1 396/1 15 397/2 2230/100 3603/20